﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WPF开发
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }      

        //按钮的点击事件
        private void button_Click(object sender, RoutedEventArgs e)
        {
            string btName = (string)((Button)sender).Content;
            MessageBox.Show("您刚才点击了 ["+ btName + "] 按钮!");
        }

        private void cbAll_Click(object sender, RoutedEventArgs e)
        {
            CheckBox cb = (CheckBox)sender;
            string cbContent = (string)cb.Content;
            
            MessageBox.Show("您刚才点击了 [" + cbContent + "] 复选框!");

            //遍历其他复选框,并选中该
            //???
        }

        //获取时间按钮的点击事件
        private void btnGetDate_Click(object sender, RoutedEventArgs e)
        {
            //先获得时间选择器的值,因为是可空类型所以加上 ? 修饰
            DateTime? date = datePicker.SelectedDate;
            if (date == null)
            {
                MessageBox.Show("请选择一个时间!");
            }
            else 
            {
                
                MessageBox.Show("您选择的时间是:\n"+date.ToString());
            }

        }

        //改变时间控件的值
        private void btnChangeTime_Click(object sender, RoutedEventArgs e)
        {
            datePicker.SelectedDate = DateTime.Today;//获得当天
            datePicker.SelectedDate = DateTime.Now;//获得当天以及详细时间
        }

        //点击按钮增加进度条的值
        private void addpgOne_Click(object sender, RoutedEventArgs e)
        {
            pgOne.Value += 10;
        }
    }
}
